package com.ck.ckcloud.networkmanagement.facade;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ck.ckcloud.networkmanagement.domain.aggregate.NetworkManagement;
import com.ck.ckcloud.networkmanagement.domain.entity.Resource;
import com.ck.ckcloud.networkmanagement.domain.service.NetworkManagementService;
import com.ck.ckcloud.networkmanagement.infrastructure.repository.NetworkManagementRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 网管门户
 * 封装了领域的业务能力
 * 暴露领域对外发布的服务
 *
 * @author Aiden <a href="mailto:adam602260@gmail.com"/>
 * @version NetworkManagementFacade.java v0.1
 * @create 2019-09-22 14:43
 */
@Component
public class NetworkManagementFacade {

	@Autowired
	private NetworkManagementRepository networkManagementRepository;

	@Autowired
	private NetworkManagementService networkManagementService;

	/**
	 * 根据资源唯一ID查询一个资源
	 * @param resourceUniqueId
	 * @return
	 */
	public Resource getResourceById(String resourceUniqueId){
		NetworkManagement networkManagement = networkManagementRepository.getNetworkManagementByResourceUniqueId(resourceUniqueId);
		return networkManagement.getResource();
	}

	/**
	 * 分页查询资源
	 * @param page
	 * @return
	 */
	public IPage listResourceByPage(Page page){
		IPage iPage = networkManagementService.listResourceByPage(page);
		return iPage;
	}


}
